package com.intel.factorytest;

import java.io.IOException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;

import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Color;

import android.os.Bundle;
import android.os.RemoteException;

import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.view.ViewGroup.LayoutParams;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.GridView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;
import android.app.StatusBarManager;

import com.intel.factorytest.NumAndResult;
import com.intel.factorytest.activity.BaseActivity;
import com.intel.factorytest.application.MATApplication;
import com.intel.factorytest.cfparser.ConfigFileParseUtil;
import com.intel.factorytest.cfparser.concrete.AConfigFileParser;
import com.intel.factorytest.log.LogWriter;

import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.view.KeyEvent;
import android.os.SystemProperties;

import java.util.ArrayList;

public class FactoryTest extends Activity {
    private final String TAG = "FactoryTest";

    protected static final String TEST_ITEM = "test_item";
    protected static final String ITEM_NAME = "item_name";
    protected static final String test_type = "FACTORY_TEST_TYPE";
    protected static final String sys_service = "SYSTEM_SERVICE_TEST";
    protected static final String TEST_ITEM_RESULT = "test_item_result";

    protected static final int TEST_SINGLE_ITEM = 0;
    protected static final int TEST_ALL_ITEM = 1;

    private String appVersion = "";
    private int mScreenOrientation;

    List<Map<String, Object>> mTestGridItems = null;

    private TextView mClickTextView;

    private ResultDataSave mTestResultData;
    private String logFileName;

    private int mTestType;
    private Button mTestAllButton;
    private TestGridAdapter mGridAdapter;
    private GridView gridview;

    private Map<String, NumAndResult> mResultMap = null;

    private String mTestItemName;
    private ScreenOrientationSave mScreenOrientatSaveData;
    public static int mIsTestAll = TEST_SINGLE_ITEM;
    private int mIsSysTest;
    private StatusBarManager mStatusBarManager;

    boolean isQwerty = false; //add by wangsm for qwerty.

    private class ScreenOrientationSave {
        String ItemName;
        int mTestAllFlag;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.d(TAG, "onCreate");
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        isQwerty = SystemProperties.getBoolean("ro.bluebank.keyboard.qwerty", false);

        PackageManager manager = this.getPackageManager();
        try {
            PackageInfo info = manager.getPackageInfo(this.getPackageName(), 0);
            appVersion = info.versionName; // 版本名，versionCode同理
        } catch (NameNotFoundException e) {
            e.printStackTrace();
        }

        if (MATApplication.mScreenOrientationDefine) {
            super.setRequestedOrientation(MATApplication.mScreenOrientation);
        }

        mScreenOrientatSaveData = (ScreenOrientationSave) getLastNonConfigurationInstance();
        if (mScreenOrientatSaveData == null) {
            mScreenOrientatSaveData = new ScreenOrientationSave();
            mScreenOrientatSaveData.ItemName = "";
            mScreenOrientatSaveData.mTestAllFlag = TEST_SINGLE_ITEM;
        }

        mTestItemName = mScreenOrientatSaveData.ItemName;
        mIsTestAll = mScreenOrientatSaveData.mTestAllFlag;

        // 设置应用语言
        updateConfiguration();

        Configuration mConfiguration = getResources().getConfiguration(); // 获取设置的配置信息
        mScreenOrientation = mConfiguration.orientation;

        setContentView(R.layout.factorytest);

        mTestType = ResultDataSave.SYSTEM_ITEM_TEST;
        mIsSysTest = 1;

        LogWriter.enable();
        logFileName = LogWriter.getFileName(LogWriter.LogType_SystemTest);

        String localeString = mConfiguration.locale.getCountry();
        localeString = "US";
        mTestGridItems = ConfigFileParseUtil.getConfParserConcrete(this,
                AConfigFileParser.EXTENSION_PROPERTISE).doParse(1, 0,
                localeString, null);

        Log.d(TAG, " mTestGridItems = " + mTestGridItems);
        ConfigFileParseUtil.getConfParserConcrete(this,
                AConfigFileParser.EXTENSION_XML).doParseCaseItem(1, 0,
                localeString, null);

        mTestResultData = new ResultDataSave();
        mTestResultData.initResultData(this, mTestType, mTestGridItems);
        mResultMap = mTestResultData.getResultData(mTestType);

        gridview = (GridView) findViewById(R.id.factorytest_gridview);
        mGridAdapter = new TestGridAdapter(this, mTestGridItems, mResultMap);
        gridview.setAdapter(mGridAdapter);
        gridview.setOnItemClickListener(new ItemClickListener());

        Log.d(TAG, "onCreate end");
    }

    public static boolean getIsTestAll() {
        return (mIsTestAll == TEST_ALL_ITEM) ? true : false;
    }

    private void AddItemToList(List<Map<String, Object>> mList) {
        //add result item
        Map<String, Object> mResultItem = new HashMap<String, Object>();
        Intent mResultIntent = new Intent();
        mResultIntent.setClassName("com.intel.factorytest",
                "com.intel.factorytest.FactoryTestResultShow");
        mResultItem.put("intent", mResultIntent);
        mResultItem.put("itemName",
                getString(R.string.factorytest_bunch_result));
        mList.add(mResultItem);

        //add result item
        Map<String, Object> mDeleteResultItem = new HashMap<String, Object>();
        Intent mDeleteResultIntent = new Intent();
        mResultIntent.setClassName("com.intel.factorytest",
                "com.intel.factorytest.FactoryTestResultShow");
        mDeleteResultItem.put("intent", mDeleteResultIntent);
        mDeleteResultItem.put("itemName",
                getString(R.string.factorytest_item_delete_result));
        mList.add(mDeleteResultItem);

        Map<String, Object> mResetPhoneItem = new HashMap<String, Object>();
        Intent mResetPhoneIntent = new Intent();
        mResetPhoneIntent.setClassName("com.intel.factorytest",
                "com.intel.factorytest.activity.ResetPhoneActivity");
        mResetPhoneItem.put("intent", mResetPhoneIntent);
        String resetPhone = getString(R.string.reset_phone);
        mResetPhoneItem.put("itemName", resetPhone);
        mList.add(mResetPhoneItem);
    }

    @Override
    public Object onRetainNonConfigurationInstance() {
        mScreenOrientatSaveData.ItemName = mTestItemName;
        mScreenOrientatSaveData.mTestAllFlag = mIsTestAll;
        return mScreenOrientatSaveData;
    }

    class ItemClickListener implements OnItemClickListener {
        public void onItemClick(AdapterView<?> parent, View v, int position,
                                long id) {
            //mClickTextView = (TextView) v;
            Map map = (Map) parent.getItemAtPosition(position);
            mTestItemName = (String) map.get("itemName");
            if (getString(R.string.factorytest_item_delete_result).equals(mTestItemName)) {
                BuildDeleteDialog();
            } else {
                Intent intent = (Intent) map.get("intent");
                intent.putExtra(test_type, mTestType);
                // intent.putExtra(sys_service, 1);
                intent.putExtra(TEST_ITEM, position);
                intent.putExtra(ITEM_NAME, mTestItemName);
                // intent.putExtra(LogWriter.LogFileNameTag, logFileName);
                try {
                    startActivityForResult(intent, position);
                } catch (Exception e) {
                    Log.e(TAG, "error: " + e.getMessage());
                }
            }
        }
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        Log.d(TAG, " the key keyCode is " + keyCode);
        if (mTestGridItems == null || keyCode == KeyEvent.KEYCODE_DPAD_UP
                || keyCode == KeyEvent.KEYCODE_DPAD_DOWN
                || keyCode == KeyEvent.KEYCODE_DPAD_LEFT
                || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
            return super.onKeyDown(keyCode, event);
        }
        Map<String, Object> map;
        int size = mTestGridItems.size();
        if (isQwerty) {
            switch (keyCode) {
                case KeyEvent.KEYCODE_W:
                    keyCode = KeyEvent.KEYCODE_1;
                    break;
                case KeyEvent.KEYCODE_E:
                    keyCode = KeyEvent.KEYCODE_2;
                    break;
                case KeyEvent.KEYCODE_R:
                    keyCode = KeyEvent.KEYCODE_3;
                    break;
                case KeyEvent.KEYCODE_S:
                    keyCode = KeyEvent.KEYCODE_4;
                    break;
                case KeyEvent.KEYCODE_D:
                    keyCode = KeyEvent.KEYCODE_5;
                    break;
                case KeyEvent.KEYCODE_F:
                    keyCode = KeyEvent.KEYCODE_6;
                    break;
                case KeyEvent.KEYCODE_Z:
                    keyCode = KeyEvent.KEYCODE_7;
                    break;
                case KeyEvent.KEYCODE_X:
                    keyCode = KeyEvent.KEYCODE_8;
                    break;
                case KeyEvent.KEYCODE_C:
                    keyCode = KeyEvent.KEYCODE_9;
                    break;
            }
        }
        int index = keyCode - KeyEvent.KEYCODE_0;
        if (0 <= index && index < size) {
            map = mTestGridItems.get(index);
            mTestItemName = (String) map.get("itemName");
            Intent intent = (Intent) map.get("intent");
            intent.putExtra(test_type, mTestType);
            intent.putExtra(TEST_ITEM, index);
            intent.putExtra(ITEM_NAME, mTestItemName);
            // intent.putExtra(LogWriter.LogFileNameTag, logFileName);
            try {
                startActivityForResult(intent, index);
            } catch (Exception e) {
                Log.e(TAG, "error");
            }
            return false;
        }
        return super.onKeyDown(keyCode, event);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        Boolean is_pass;
        int test_pos;

        if (data != null && mTestItemName != null) {
            is_pass = data.getBooleanExtra(TEST_ITEM_RESULT, false);
            test_pos = data.getIntExtra(TEST_ITEM, -1);
            String versionTest = getString(R.string.version_test);
            String testTorch = getString(R.string.torch_test);
            String testBacklight = getString(R.string.backlight_test);
            String testBluetooth = getString(R.string.bluetooth_test);
            String testWifi = getString(R.string.wifi_test);
            String testMicrophoneSub = getString(R.string.microphone_sub_test);
            Log.i(TAG, "is_pass=" + is_pass + " test_pos=" + test_pos + " mTestItemName=" + mTestItemName);
            if (mTestItemName.equals("System Info")
                    || mTestItemName.equals("LED")
                    || mTestItemName.equals("Audio Jack")
                    || mTestItemName.equals("Back mic")
                    || mTestItemName.equals("Top Front mic")
                    || mTestItemName.equals("Bottom Front mic")
                    || mTestItemName.equals("Earpiece 1Khz")
                    || mTestItemName.equals("Earpiece Music")
                    || mTestItemName.equals("Speaker 1Khz")
                    || mTestItemName.equals("Speaker music")
                    || mTestItemName.equals("Touch screen")
                    || mTestItemName.equals("Display Brightness")
                    || mTestItemName.equals("Display Pattern")
                    || mTestItemName.equals("Back Camera")
                    || mTestItemName.equals("Camera back Flash")
                    || mTestItemName.equals("Front Camera")
                    || mTestItemName.equals("Micro SD Card")
                    || mTestItemName.equals("Nano Sim")
                    || mTestItemName.equals("Vibrator")
                    || mTestItemName.equals("Sensors")
                    || mTestItemName.equals("Battery")
                    || mTestItemName.equals("Bluetooth test")
                    || mTestItemName.equals("Wifi test")
                    || mTestItemName.equals("GPS Location")
                    || mTestItemName.equals("Earpiece 1Khz")
                    || mTestItemName.equals("Speaker 1Khz")
                    || mTestItemName.equals("Key & Button")
                    || mTestItemName.equals("Top Front mic")
                    || mTestItemName.equals("SARSensor")
                    || mTestItemName.equals("Volume Knob")
                    || mTestItemName.equals("Mic Test")
                    || mTestItemName.equals("Sub Mic Test")
                    || mTestItemName.equals("USB")
                    || mTestItemName.equals("FM Test")
                    || mTestItemName.equals("RTC")
                    || mTestItemName.equals("Call Test")
                    || mTestItemName.equals("OTG test")
                    || mTestItemName.equals("AOV test")
            ) {
                if (is_pass) {
                    mTestResultData.setDataOfList(mTestType, mTestItemName,
                            test_pos, ResultDataSave.ITEM_TEST_SUCCES);
                } else {
                    mTestResultData.setDataOfList(mTestType, mTestItemName,
                            test_pos, ResultDataSave.ITEM_TEST_FAIL);
                }
                mTestResultData.SaveResultData(this, mTestType, mTestGridItems);//add by wangsm for save data
                if (is_pass) {
                    mTestResultData.resultSaveToFile(test_pos, '1');
                } else {
                    mTestResultData.resultSaveToFile(test_pos, '0');
                }

                if (mIsTestAll == TEST_ALL_ITEM) {
                    if (test_pos + 1 == (mGridAdapter.getCount() - 2)) {
                        Log.d(TAG, "SaveResultData...");
                    }
                    if (test_pos + 1 < (mGridAdapter.getCount() - 2)) {
                        Map map = (Map) mGridAdapter.getItem(test_pos + 1);
                        Intent intent = (Intent) map.get("intent");
                        intent.putExtra(TEST_ITEM, test_pos + 1);
                        intent.putExtra(sys_service, mIsSysTest);
                        intent.putExtra(ITEM_NAME, (String) map.get("itemName"));
                        intent.putExtra(LogWriter.LogFileNameTag, logFileName);
                        mTestItemName = (String) map.get("itemName");
                        FactoryTest.this.startActivityForResult(intent,
                                test_pos + 1);
                        return;
                    }
                }

                mGridAdapter.notifyDataSetChanged();

            } else {
                Log.e(TAG, "no name");
                mTestResultData.setDataOfList(mTestType, mTestItemName,
                        test_pos, ResultDataSave.ITEM_EXTERN);
                mGridAdapter.notifyDataSetChanged();
                mIsTestAll = TEST_SINGLE_ITEM;
            }
        } else if (getString(R.string.factorytest_bunch_result).equals(
                mTestItemName)) {
            Log.e(TAG, "show test result");
            if (mIsTestAll == TEST_ALL_ITEM) {
            }
            mGridAdapter.notifyDataSetChanged();
            mIsTestAll = TEST_SINGLE_ITEM;
        }
    }

    protected static int getTestAllMode() {
        return mIsTestAll;
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        outState.putString("mTestItemName", mTestItemName);
        super.onSaveInstanceState(outState);
        Log.d(TAG, "onSaveInstanceState");
    }

    @Override
    protected void onRestoreInstanceState(Bundle savedInstanceState) {
        mTestItemName = savedInstanceState.getString("mTestItemName");
        super.onRestoreInstanceState(savedInstanceState);
        Log.d(TAG, "onRestoreInstanceState");
    }

    protected void onResume() {
        Log.d(TAG, "onResume");
        super.onResume();
        SystemProperties.set("sys.cit.key.test", "true");
    }

    @Override
    public void onPause() {
        Log.d(TAG, "onPause");
        super.onPause();
        SystemProperties.set("sys.cit.key.test", "false");
    }

    @Override
    public void finish() {
        mTestResultData.SaveResultData(this, mTestType, mTestGridItems);
        try {
            mTestResultData.SaveResultToBinary(mTestType);
        } catch (IOException e) {
            e.printStackTrace();
        }
        Log.d(TAG, "finish");
        super.finish();
    }

    @Override
    public void onStop() {
        Log.d(TAG, "onStop");
        super.onStop();
    }

    @Override
    public void onDestroy() {
        Log.e(TAG, "onDestroy");
//         int state =  StatusBarManager.DISABLE_NONE;  
//         mStatusBarManager.disable(state); 
        super.onDestroy();
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        Resources resourse = this.getResources();
        Configuration config = resourse.getConfiguration();
        SharedPreferences pre = getSharedPreferences(
                MATApplication.LANGUAGE_PREF, Context.MODE_PRIVATE);
        String lanPre = pre.getString(MATApplication.LANGUAGE_KEY, "zh");
        if (lanPre.equals("zh")) {
            config.locale = Locale.SIMPLIFIED_CHINESE;
        } else {
            config.locale = Locale.ENGLISH;
        }
        Locale.setDefault(config.locale);
        this.getBaseContext().getResources()
                .updateConfiguration(config, resourse.getDisplayMetrics());
    }

    protected void updateConfiguration() {
        Resources resourse = this.getResources();
        Configuration config = resourse.getConfiguration();
        SharedPreferences pre = getSharedPreferences(
                MATApplication.LANGUAGE_PREF, Context.MODE_PRIVATE);
        String lanPre = pre.getString(MATApplication.LANGUAGE_KEY, "zh");
        if (lanPre.equals("zh")) {
            config.locale = Locale.SIMPLIFIED_CHINESE;
        } else {
            config.locale = Locale.ENGLISH;
        }
        Locale.setDefault(config.locale);
        this.getBaseContext().getResources()
                .updateConfiguration(config, resourse.getDisplayMetrics());
    }

    protected void BuildDeleteDialog() {
        AlertDialog.Builder builder = new Builder(this);
        builder.setMessage(getString(R.string.factorytest_delete_result_note));
        builder.setTitle(getString(R.string.factorytest_delete_result_title));
        //add by wangsm
        LayoutInflater inflater = LayoutInflater.from(this);
        View view = inflater.inflate(R.layout.del_result_dialog_result, null);
        Button ok = (Button) view.findViewById(R.id.del_ok);
        Button cancel = (Button) view.findViewById(R.id.del_cancel);
        builder.setView(view);

        //del by wangsm
        /*builder.setPositiveButton(getString(R.string.SERVICEMENU_OK_TXT), new OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub
                mTestResultData.DeleteResult(getBaseContext(),mTestType);
                mTestResultData.SaveResultData(getBaseContext(), mTestType, mTestGridItems);
                mGridAdapter.notifyDataSetChanged();
                dialog.dismiss();
            }
        });

        builder.setNegativeButton(getString(R.string.SERVICEMENU_CANCEL_TXT), new OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub
                 dialog.dismiss();
            }
        });*/

        final AlertDialog dialog = builder.create();
        //add by wangsm
        ok.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mTestResultData.DeleteResult(getBaseContext(), mTestType);
                mTestResultData.SaveResultData(getBaseContext(), mTestType, mTestGridItems);
                mGridAdapter.notifyDataSetChanged();
                dialog.dismiss();
            }
        });
        cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialog.dismiss();
            }
        });
        dialog.show();
        //end by wangsm
    }

    public class TestGridAdapter extends BaseAdapter {
        Context mContext;
        private List<Map<String, Object>> summary;
        private Map<String, NumAndResult> mResultMap;

        public TestGridAdapter(Context context,
                               List<Map<String, Object>> summarys,
                               Map<String, NumAndResult> ResultMap) {
            mContext = context;
            summary = summarys;
            mResultMap = ResultMap;
        }

        public int getCount() {
            return summary.size();
        }

        public Object getItem(int position) {
            return summary.get(position);
        }

        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            // TODO Auto-generated method stub
            String mItemName;
            TextView view;
            int hight;
            NumAndResult mIndexResult;
            int mItemResult;
            ItemHolder mHolder;
            //Log.d(TAG, "position:" + position);
            // Log.e(TAG, "imgSource.get(position):"+imgSource.get(position));

            Map map = (Map) summary.get(position);
            mItemName = (String) map.get("itemName");
//            Log.d(TAG, "position:" + position+"   mItemName:"+mItemName);

            mIndexResult = mResultMap.get(mItemName);
            if (mIndexResult == null) {
                mItemResult = ResultDataSave.ITEM_EXTERN;
            } else {
                mItemResult = mIndexResult.mResult;
            }

            if (convertView == null) // if it's not recycled, initialize some
            {
                LayoutInflater inflater = LayoutInflater.from(mContext);
                convertView = inflater.inflate(R.layout.factorytest_item, null);
                mHolder = new ItemHolder();
                mHolder.layout = (LinearLayout) convertView.findViewById(R.id.test_layout);
                mHolder.number = (TextView) convertView.findViewById(R.id.test_number);
                mHolder.name = (TextView) convertView.findViewById(R.id.test_name);
                DisplayMetrics metric = new DisplayMetrics();
                getWindowManager().getDefaultDisplay().getMetrics(metric);
                if (mScreenOrientation == Configuration.ORIENTATION_LANDSCAPE) {
                    //hight = metric.heightPixels / 3;
                    hight = metric.widthPixels / 3;
                } else {
                    hight = metric.heightPixels / 3;
                    //hight = metric.widthPixels / 3;
                }
                mHolder.layout.setLayoutParams(new GridView.LayoutParams(
                        LayoutParams.MATCH_PARENT, hight));
                convertView.setTag(mHolder);

                /*view = new TextView(mContext);

                DisplayMetrics metric = new DisplayMetrics();
                getWindowManager().getDefaultDisplay().getMetrics(metric);
                if (mScreenOrientation == Configuration.ORIENTATION_LANDSCAPE) {
                    hight = metric.heightPixels / 3;
                } else {
                    hight = metric.widthPixels / 3;
                }

                view.setText(mItemName);

                view.setLayoutParams(new GridView.LayoutParams(
                        LayoutParams.MATCH_PARENT, hight));
                view.setTextSize(20);
                view.setTextColor(Color.BLACK);
                view.setGravity(Gravity.CENTER);*/
            } else {
                mHolder = (ItemHolder) convertView.getTag();
                //view = (TextView) convertView; // references to our images
            }
            String number = String.valueOf(position);
            mHolder.number.setText(number);
            mHolder.name.setText(mItemName);

            if (mItemResult == ResultDataSave.ITEM_TEST_SUCCES) {
                mHolder.layout.setBackgroundColor(Color.GREEN);
            } else if (mItemResult == ResultDataSave.ITEM_TEST_FAIL) {
                mHolder.layout.setBackgroundColor(Color.RED);
            } else if (mItemResult == ResultDataSave.ITEM_DONOT_TEST) {
                mHolder.layout.setBackgroundColor(Color.WHITE);
            } else {
                mHolder.layout.setBackgroundColor(Color.WHITE);
            }
/*            view.setText(mItemName);

            if (mItemResult == ResultDataSave.ITEM_TEST_SUCCES) {
                view.setBackgroundColor(Color.GREEN);
            } else if (mItemResult == ResultDataSave.ITEM_TEST_FAIL) {
                view.setBackgroundColor(Color.RED);
            } else if (mItemResult == ResultDataSave.ITEM_DONOT_TEST) {
                view.setBackgroundColor(Color.WHITE);
            } else {
                // view.setBackgroundColor(Color.CYAN);
                view.setBackgroundColor(Color.WHITE);
            }
            return view;
*/
            return convertView;
        }

        private class ItemHolder {
            LinearLayout layout;
            TextView number;
            TextView name;
        }
    }
}